package com.hand.wfive.loginAndVip.model

import com.hand.wfive.loginAndVip.VipConfig
import org.litepal.crud.LitePalSupport

class VipActivityModel {
    var code = 0
    var msg = ""
    var obj: ActivityConfigModel? = null
    val couponList: List<CouponModel>? = null
}

class ActivityConfigModel {
    var id = 0L
    var activeId = ""
    var activeType = -1 //  新人活动:1 , 限时优惠活动:2
    var activeName = ""
    var vipKey = ""
    var appid = ""
    var appName = ""
    var state = -1
    var stTime = ""
    var endTime = ""
    var saleCycle = 0L //限时活动周期 单位：分钟
    var newUserTime = 0L //新人活动周期 单位：毫秒
    var oldPrice = ""
    var newPrice = ""
    var saleBanner = ""
    var paperWork = ""
    var createDate = ""
    var updateDate = ""
    var remark = ""
    var backgroundUrl: String? = null
    var imageUrl: String? = null //倒计时背景
    var activityDeadline = 0L //活动倒计时时间 单位：毫秒

    /**
     * 新人活动后台已经计算了 ，无需本地存储
     */
    fun isNeedSaveStartTime(): Boolean {
        return activeType == 2 || activeType == 3
    }

    /**
     * 获取倒计时毫秒
     */
    fun getDownTimeMills(): Long {
        return when (activeType) {
            1 -> {
                newUserTime
            }
            2 -> {
                saleCycle * 60 * 1000
            }
            else -> {
                activityDeadline
            }
        }
    }
}

class CouponModel : LitePalSupport() {
    var id = 0L
    var cDown = 0L // 分钟
    var price = ""
    var retUrl = ""
    var retContent = ""
    var vipType = ""
    var vipTimes: String? = null // vipType 7 次卡 次数
    var notifiType = 0

    /**
     * 优惠券开始时间
     * 小于等于0 :优惠券未领取,或者已过期，
     * 大于0：优惠券可以正常使用
     */
    var couponStartTime = 0L

    /**
     * 获取总倒计时毫秒
     */
    fun getDownTimeMills(): Long {
        return cDown * 60 * 1000
    }

    fun getVipValueByValue(): String {
        return VipConfig.getVipLableByValue(vipType)
    }
}

class PreferentialConfigModel {
    var code = 0
    var msg = ""
    var obj = ArrayList<CouponModel>()
}